<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <?php echo XXF_LNAME?><br><input type="hidden" id="uid" name="x" value="<?php echo XXF_UID?>">
                            <select id="shiqi" name="x">
                            	<option value="0">请选择时期</option>
                                	<?php
	                            	for($j=0;$j<3;$j++){
	                            	?>
	                            	<option value="<?php echo date('Y')-$j+1;?>年度" <?php echo (date('Y')==(date('Y')-$j+1))?"selected":"" ?>><?php echo date('Y')-$j+1;?>年度</option>
	                            	<?php
	                            	}
	                            	?>
                            </select>
                            <input type="text" id="youbian" name="x" placeholder="邮编" title="邮编"  style="width: 50px;font-size: 10px;" value="<?php echo gconf("web", "youbian")?>">
                            <input type="text" id="dianhua" name="x" placeholder="电话" title="电话"  style="width: 60px;font-size: 10px;" value="<?php echo gconf("web", "unitphone")?>">
                            <input type="text" id="peixunaddress" name="x" placeholder="培训地址" title="培训地址" value="重庆煤矿安全技术培训中心" style="font-size: 10px;">
                            <input type="text" id="lilunaddress" name="x" placeholder="理论考试地址" title="理论考试地址" value="安培中心网络考试中心" style="font-size: 10px;">
                            <br>
                            <select id="bzrid" name="x">
                            	<option value="0">选择班主任</option>
                            	<?php foreach ($bzr as $row){
                            	?>
                            		<option value="<?php echo $row['id']?>"><?php echo $row['realname']?></option>
                            	<?php 
                            	}?>
                            </select>
                            <input type="text" id="stime" name="x" placeholder="开班时间" title="开班时间" style="width: 80px;font-size: 10px;" readonly>
                            <input type="text" id="etime" name="x" placeholder="结班时间"  title="结班时间" style="width: 80px;font-size: 10px;" readonly>
                            <input type="text" id="pname" name="x" placeholder="班级名称" title="班级名称"  style="width: 180px;font-size: 10px;">
                            <select id="xinfuxun" name="x">
                            	<option value="0">请选择新复训</option>
                            	<option>新训</option>
                            	<option>复训</option>
                            	<option>专项培训</option>
                            </select>
                            <input type="button" id="add" value="添加" onclick="add()">
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>班级名称</th>
                                        <th>新复训</th>
                                        <th>时间</th>
                                        <th>班主任</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA <?php echo ((date("Y-m-d")>$row['stime'])&&(date("Y-m-d")<$row['etime']))?("success"):""?>" id='<?php echo $row['pid'];?>'>
                                        <td><?php echo $row['pid'];?></td>
                                        <td><?php echo $row['pname'];?></td>
                                        <td><?php echo $row['xinfuxun'];?></td>
                                    	<td><?php echo $row['shiqi']."[".substr($row['stime'],5,5).":".substr($row['etime'],5,5)."]";?></td>
                                        <td><?php echo $row['realname'];?></td>
                                        <td><a href="javascript:del(<?php echo $row['pid']?>)">删除</a></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]]
        });
        $("#stime").click(function(){$(this).xrili();});
        $("#etime").click(function(){$(this).xrili();});
    });
   
    function del(pid){
		$.xconfirm("删除后无法恢复，确定要删除此条记录么？",function(data){
 			if(data){
				$.xloading(1);
				$.post("pxb",{type:'del',pid:pid},function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("删除失败");
					}else{
						window.location.reload();
					}
				}); 
			} 
		});
    }
    function add(){
		var shiqi=$("#shiqi").val();
 		var bzrid=$("#bzrid").val();
 		var pname=$("#pname").val();
 		var stime=$("#stime").val();
 		var etime=$("#etime").val();
 		var xinfuxun=$("#xinfuxun").val();
 		var peixunaddress=$("#peixunaddress").val();
 		var lilunaddress=$("#lilunaddress").val();
 		if(shiqi=="0"||bzrid=="0"||pname.length<1||stime.length<1||etime.length<1||lilunaddress.length<1||peixunaddress.length<1||xinfuxun=="0"){
			$.xalert("请将信息填写完整！");return false;
 	 	}
 		$.xconfirm("确定添加？",function(data){
 			if(data){
				$.xtodb("add","peixunban",$("[name='x']"),"bzrid_pname_shiqi",function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("添加失败");
					}else{
						window.location.reload();
					}
				});
			} 
		});
    }    
    </script>